var app = angular.module('webapp');

app.service('LoginService', ['$http','$q', LoginService]);

function LoginService($http,$q){
	function handleRequest(method , url , data){
        var defered = $q.defer();
        var config = {
            method : method,
            url : url
        };
        if('POST' === method){
            config.data = data;
        }else if('GET' === method){
            config.params = data;
        }

        $http(config).success(function(data){
            defered.resolve(data);
        }).error(function(err){
            defered.reject(err);
        });
        return defered.promise;
    }
    return {
        getByUser:function(data){
            return handleRequest('POST','/getByUser',data);
        }
    }
}